# Makefile to batch run R scripts and save logs

R_SCRIPTS = analysis_2021-05 analysis_2021-08 analysis_2022-08
LOG_DIR = log
CODE_DIR = code

all: mkdir $(R_SCRIPTS:%=$(LOG_DIR)/%.Rout) code/load.R

# Pattern rule to create log files from R scripts
$(LOG_DIR)/%.Rout: $(CODE_DIR)/%.R
	R CMD BATCH $< $@

mkdir:
	mkdir -p txt
	mkdir -p txt/fig
	mkdir -p log

# start fresh
clean:
	rm -rf log
	rm -rf txt
	rm -f .RData

.PHONY: all clean mkdir
